package com.zhangxun.service.impl;

import cn.hutool.core.util.ObjectUtil;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.zhangxun.domain.Notice;
import com.zhangxun.service.NoticeService;
import com.zhangxun.mapper.NoticeMapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.util.StringUtils;

/**
* @author 张循
* @description 针对表【notice】的数据库操作Service实现
* @createDate 2023-01-05 18:32:47
*/
@Service
public class NoticeServiceImpl extends ServiceImpl<NoticeMapper, Notice>
    implements NoticeService{

    @Autowired
    private NoticeMapper noticeMapper;

    @Override
    public Page<Notice> selectPage(Page<Notice> page, Notice notice) {

        page = noticeMapper.selectPage(page,new LambdaQueryWrapper<Notice>()
                .like(StringUtils.hasText(notice.getTitle()),Notice::getTitle,notice.getTitle())
                .eq(ObjectUtil.isNotNull(notice.getStatus()),Notice::getStatus,notice.getStatus())
                .eq(ObjectUtil.isNotNull(notice.getIsTop()),Notice::getIsTop,notice.getIsTop()));

        return page;


    }
}




